﻿using System.ComponentModel.Composition.Hosting;
using System.Windows;
using DiagramDesigner.Common.Services.Interfaces;
using DiagramDesigner.Module.Canvas;
using DiagramDesigner.Module.StatusBar;
using DiagramDesigner.Module.Toolbar;
using DiagramDesigner.Module.Toolbox;
using Microsoft.Practices.Prism.MefExtensions;

namespace DiagramDesigner.Desktop
{
    public class Bootstrapper : MefBootstrapper
    {
        protected override DependencyObject CreateShell()
        {
            return Container.GetExportedValue<Shell>();
        }

        protected override void InitializeShell()
        {
            base.InitializeShell();
            Application.Current.MainWindow = (Window) this.Shell;
            Application.Current.MainWindow.Show();
        }


        protected override void ConfigureAggregateCatalog()
        {
            base.ConfigureAggregateCatalog();

            
            this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(GetType().Assembly));
            
            this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(ToolbarModule).Assembly));
            this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(ToolboxModule).Assembly));
            this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(CanvasModule).Assembly));
            this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(StatusBarModule).Assembly));
            this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(IPluginsLoaderService<>).Assembly));
        }
    }
}
